<?php

namespace app\api\model;

use think\Model;

class Group extends Model
{

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';


    /**
     * 获取群详情
     * @param $group_id int 群组ID
     * @param $user_id int  用户ID
     * @return array|false|\PDOStatement|string|Model
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getDetail($group_id,$user_id)
    {
        $data = $this->where('group_id', $group_id)->field('group_id,group_name,introduction,avatar,status')->find();
        $data['auth'] = model('group_user')->where(['group_id'=>$group_id,'user_id'=>$user_id])->value('auth');
        return $data;
    }
}